<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\logic\MenuLogic;
use Illuminate\Http\Request;

class MenuController extends BaseController
{
    /**
     * 获取小程序菜单
     * @return \Illuminate\Http\JsonResponse
     */
    public function index()
    {
        try {
            $data = MenuLogic::index();
            return $this->witejson(0,$data,'操作成功');
        }catch (\Exception $e) {
            return $this->witejson(101,'null',$e->getMessage());
        }
    }

    /**
     * 获取小程序子菜单
     * @param Request $request
     */
    public function menuson(Request $request)
    {
        try {
            $pid = $request->get('pid');
            $data = MenuLogic::getMenuSon($pid);
            return $this->witejson(0,$data,'操作成功');
        }catch (\Exception $e){
            return $this->witejson(101,'null',$e->getMessage());

        }
    }
}
